/**
 * mixin的作用是将组件中的公共逻辑提取出来，
 * 写法和组件中options选项一样，
 * 使用的时候会合并，不会替换
 */
export default {
  mounted () {
    this.initEvent()
  },
  destroyed() {
    window.removeEventListener('scroll', this.scroll)
  },
  methods: {
    initEvent () {
      window.addEventListener('scroll', this.scroll)
    },
    scroll () {
      console.log('aaa')
      const [
        scrollY,
        viewHeight,
        documentHeight
      ] = [
        window.scrollY,
        window.innerHeight,
        document.body.clientHeight
      ]
      if (scrollY + viewHeight === documentHeight) {
        this.onScrollBottom()
      }
    }
  }
}
